<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>html5</title>
</head>
<body  > 
<div id="table">
<table width="333" border="1" >
  <tr>
    <td width="133">你好</td>
    <td width="99">hello</td>
    <td width="99">&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>很好</td>
    <td>&nbsp;</td>
    <td>呵呵</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td> 哈哈 </td>
  </tr>
</table>
</div>

    <button onclick="dlexcel()" >下载excel</button>
    
    <p id="cvs">
    666,setwert
    nasdadadsa,5464646,asdadad
    </p>
    
    <button onclick="dlcvs()">下载cvs</button>
    <button onclick="dlJPG()">JPG</button>
    <button >js文件</button>
    
</body></html>

<script type="text/javascript">
function blobdl(blob,filename)
{
	
 if (window.navigator.msSaveOrOpenBlob) {
		navigator.msSaveBlob(blob, filename);//兼容IE
    }
	else
	{
		var link = document.createElement('a');
		link.href = window.URL.createObjectURL(blob);
		link.download = filename;
		document.body.append(link);
		link.click();
		window.URL.revokeObjectURL(link.href);
		document.body.removeChild(link);
    }
}

function dlexcel()
{
	var table= document.getElementById("table").innerHTML
	const bdata = new Blob(['\uFEFF'+table], { type: 'application/vnd.ms-excel' });//application/vnd.ms-excel,charset=UTF-8
    blobdl(bdata,"excel.xls")
}

function dlcvs()
{
	var table= document.getElementById("cvs").innerHTML;
	const bdata = new Blob(['\uFEFF'+table], { type: 'application/octet-stream' });//application/vnd.ms-excel,charset=UTF-8
    blobdl(bdata,"excel.csv")
}


    var blob="666\setwert\r\nasdadadsa\r5464646\nasdadad";
    var lHtml = "<table border='1' style='width: 750px;height: 242px; border:1px solid ;border-collapse: collapse;border-color:#000;background-color:white;' align='center'><tr style='border: 0px;'><td colspan='5' style='height: 50px;font-size:21px;text-align: center;border: 0px;font-weight: bold;'> 硕大的 </td></tr></table>"

   // var tableHtml='<html><head><meta charset="UTF-8"></head><body>';
//tableHtml += lHtml;
//tableHtml += '</body></html>';




</script>